﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
using UnityEngine.UI;

public class UICtrl : MonoBehaviour
{
    [SerializeField]
    private Button skillButton;

    private GameObject effectGo;
    public TimeLineCtrl timeLineCtrl;

    public Transform playerTrans;

    public Transform enemyTrans;
    // Start is called before the first frame update
    void Start()
    {
        skillButton.onClick.AddListener(OnBtnClick);
    }


    void LoadEffectGo()
    {
        GameObject gob = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/AssetsPackage/Skills/Prefabs/80002.prefab");
        effectGo = Instantiate(gob);
    }

    // Update is called once per frame
    void OnBtnClick()
    {
        if (effectGo == null)
        {
            LoadEffectGo();
        }
        else
        {
            effectGo.SetActive(true);
        }

        
        //你向对方丢了一个技能
        timeLineCtrl.BindTimeLine(effectGo.transform, playerTrans, enemyTrans);
        timeLineCtrl.PlayTimeLine(() =>
        {
            effectGo.SetActive(false);
        });
    }

    private void OnApplicationQuit()
    {
        timeLineCtrl.RemoveTrace();
    }
}
